<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('附件列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>文件名称：</label>
                                <input type="text" name="originalFilename"/>
                            </li>
<!--                            <li>-->
<!--                                <label>上传名称：</label>-->
<!--                                <input type="text" name="fileName"/>-->
<!--                            </li>-->
                            <li>
                                <label>地址：</label>
                                <input type="text" name="filePath"/>
                            </li>
                            <li>
                                <label>关联序号：</label>
                                <input type="text" name="relateId" th:value="${relateId}"/>
                            </li>
                            <li>
                                <label>关联菜单：</label>
                                <input type="hidden" id="relateMode000" th:value="${relateMode}">
                                <select id="relateMode" name="relateMode" th:with="type=${@dict.getType('cd_relate_mode')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:checked="${dict.default}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="cd:programFile:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="cd:programFile:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('cd:programFile:edit')}]];
        var removeFlag = [[${@permission.hasPermi('cd:programFile:remove')}]];
        var relateModeDatas = [[${@dict.getType('cd_relate_mode')}]];
        var prefix = ctx + "cd/programFile";
        $(function() {
            var options = {
                url: prefix + "/list",
                queryParams: queryParams,
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "附件",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'relateId',
                    title: '关联序号'
                },
                {
                    field: 'relateMode',
                    title: '关联菜单',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(relateModeDatas, value);
                    }
                },
                {
                    field: 'originalFilename',
                    title: '文件名称'
                },
                // {
                //     field: 'fileName',
                //     title: '上传名称'
                // },
                {
                    field: 'filePath',
                    title: '地址',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push("<a href="+value+">"+value+"</a>");
                        return actions.join('');
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        //方法1：监控一下下拉框，若有值的变动，则修改relateMode000的值，否则跳过去的页面不能修改项目
        //todd  方法2：若为跳转过去的页面，将下拉框变为disable的,或者隐藏类型等等
        function queryParams(params) {
            var search = $.table.queryParams(params);

            var relateModeSea = $("#relateMode000").val();
            console.log('---跳转携带值--',relateModeSea)
            if($("#relateMode000").val()==null||$("#relateMode000").val()==''){
                relateModeSea = $.form.selectSelects("relateMode");
            }else{
                $("#relateMode").css('pointer-events', 'none'); // 去除鼠标事件
                // $("#relateMode").css('pointer-events', 'auto'); // 恢复鼠标事件
            }

            search.relateMode = relateModeSea;
            return search;
        }
    </script>
</body>
</html>
